package com.hunt.service.impl;

import com.alibaba.fastjson.JSON;
import com.hunt.dao.HotMoneyMapper;
import com.hunt.model.entity.*;
import com.hunt.service.HotMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@Service
@Transactional
public class HotMoneyServiceImpl implements HotMoneyService {
    @Autowired
    private HotMoneyMapper hotMoneyMapper;
    @Override
    public List<StockHotTu> getStockHotTu() {
        return hotMoneyMapper.getStockHotTu();
    }

    @Override
    public List<StockHotDaily> getStockHotDaily(String position,String size, String orderfield,String sort) {
        List<StockHotDaily> shd=hotMoneyMapper.getStockHotDaily(position,size,orderfield,sort);
        List<StockHotSeat> lhs=hotMoneyMapper.getStockHotSeat();

        for(StockHotDaily stockHotDaily:shd){
            String seat=stockHotDaily.getSeat();
            StringBuilder seat1= new StringBuilder();
            for(StockHotSeat shs:lhs){
                String[]strings=seat.split("/");
                List<String> aa=Arrays.asList(strings);
                if( aa.contains(shs.getSeatId())){
                    seat1.append(shs.getSeatName());
                    seat1.append(",");

                }
            }
            stockHotDaily.setSeat(seat1.substring(0, seat1.length() - 1));
        }
        return shd;
    }

    @Override
    public List<StockHotRecently> getStockHotRecently(String type,String position,String size, String orderfield,String sort) {
        return hotMoneyMapper.getStockHotRecently(type,position,size,orderfield,sort);
    }

    @Override
    public List<StockHotInvest> getStockHotInvest(String sort,String position,String size) {
        return hotMoneyMapper.getStockHotInvest(sort,position,size);
    }

    @Override
    public StockHotInvest getOneStockHotInvest( String id) {
        return hotMoneyMapper.getOneStockHotInvest(id);
    }
}
